package com.ruoyi.operation.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.operation.domain.StudentInfo;
import com.ruoyi.operation.mapper.StudentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.operation.mapper.LessonInfoMapper;
import com.ruoyi.operation.domain.LessonInfo;
import com.ruoyi.operation.service.ILessonInfoService;

/**
 * 课程信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@Service
public class LessonInfoServiceImpl implements ILessonInfoService 
{
    @Autowired
    private LessonInfoMapper lessonInfoMapper;
    @Autowired
    private StudentInfoMapper studentInfoMapper;

    /**
     * 查询课程信息
     * 
     * @param id 课程信息主键
     * @return 课程信息
     */
    @Override
    public LessonInfo selectLessonInfoById(Long id)
    {
        return lessonInfoMapper.selectLessonInfoById(id);
    }

    /**
     * 查询课程信息列表
     * 
     * @param lessonInfo 课程信息
     * @return 课程信息
     */
    @Override
    public List<LessonInfo> selectLessonInfoList(LessonInfo lessonInfo)
    {
        //非管理员只能查自己的
        if (!SecurityUtils.hasRole("1")) {
            lessonInfo.setYhid(SecurityUtils.getUserId());
        }
        return lessonInfoMapper.selectLessonInfoList(lessonInfo);
    }

    /**
     * 新增课程信息
     * 
     * @param lessonInfo 课程信息
     * @return 结果
     */
    @Override
    public int insertLessonInfo(LessonInfo lessonInfo)
    {
        return lessonInfoMapper.insertLessonInfo(lessonInfo);
    }

    /**
     * 修改课程信息
     * 
     * @param lessonInfo 课程信息
     * @return 结果
     */
    @Override
    public int updateLessonInfo(LessonInfo lessonInfo)
    {
        return lessonInfoMapper.updateLessonInfo(lessonInfo);
    }

    /**
     * 批量删除课程信息
     * 
     * @param ids 需要删除的课程信息主键
     * @return 结果
     */
    @Override
    public int deleteLessonInfoByIds(Long[] ids)
    {
        return lessonInfoMapper.deleteLessonInfoByIds(ids);
    }

    /**
     * 删除课程信息信息
     * 
     * @param id 课程信息主键
     * @return 结果
     */
    @Override
    public int deleteLessonInfoById(Long id)
    {
        return lessonInfoMapper.deleteLessonInfoById(id);
    }
}
